package com.sm.li.common.valid.anno;

import io.swagger.models.auth.In;
import org.springframework.util.CollectionUtils;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import java.util.List;
import java.util.Set;

public class RegularHandler implements ConstraintValidator<Regular,Integer> {

    private List<Integer> list;

    @Override
    public void initialize(Regular constraintAnnotation) {
        int[] values = constraintAnnotation.values();
        list = CollectionUtils.arrayToList(values);
    }

    @Override
    public boolean isValid(Integer integer, ConstraintValidatorContext constraintValidatorContext) {

        return list.contains(integer);
    }
}
